//
//  TabBarC.m
//  DataStatistics
//
//  Created by Kang on 15/12/25.
//  Copyright © 2015年 YTYangK. All rights reserved.
//

#import "TabBarC.h"
#import "TabBar.h"


//#import "HomeVC.h"
//#import "EquipmenVC.h"
//#import "MoreViewController.h"
//#import "UserVC.h"

#import "SearchVC.h"


@interface TabBarC ()<UITabBarControllerDelegate>
{
    NSUInteger _lastSelectedIndex;
    UIView *_imageView;
    CAKeyframeAnimation *_animation;
}
@property (copy, nonatomic) NSString *NavigationItemTitle;
@property (weak, nonatomic) MoreViewController * morevc;

@property (weak, nonatomic) UIButton *selectedBtn;

@end

@implementation TabBarC


+ (void)initialize {

    NSMutableDictionary *dir1 = [NSMutableDictionary dictionary];
    dir1[NSForegroundColorAttributeName] = RGB(253, 135, 59, 1);
    
    
    [UITabBar appearance].tintColor = RGB(253, 135, 59, 1);
    
    [[UITabBarItem appearance].image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [[UITabBarItem appearance].selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    
    [UITabBar appearance].translucent = NO; //半透明
   // [[UITabBar appearance] setBarTintColor:RGB(21, 26, 34, 1)];//背景颜色
   [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"bottom-bg"]];
   [[UITabBarItem appearance] setTitleTextAttributes:[NSMutableDictionary dictionaryWithObject:RGB(212, 212, 212, 1) forKey:NSForegroundColorAttributeName] forState:UIControlStateNormal];
    
    [[UITabBarItem appearance] setTitleTextAttributes:dir1 forState:UIControlStateSelected];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    

  
    
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(homeBadgeNumber:) name:BADGE_Num object:nil]; // 前台运行时
    
}


// 创建自定义的tabbar
- (void)addCustomTabBar {
    
    TabBar *customTabBar = [[TabBar alloc] init];
   // customTabBar.delegate = self;
    //更换系统自带的tabbar
   [self setValue:customTabBar forKey:@"tabBar"];
    
}

- (void)homeBadgeNumber:(NSNotification *)text {
    [[NSNotificationCenter defaultCenter] removeObserver:BADGE_Num];
    [[NSNotificationCenter defaultCenter] removeObserver:UIApplicationDidBecomeActiveNotification];
    [[NSNotificationCenter defaultCenter] postNotificationName:MDC_SET_BADGE object:self userInfo:[text userInfo]];
}







- (void)addAllChildVCs {
    
   /* HomeVC *home = [[HomeVC alloc] init];
    [self addOneChildVC:home title:@"Home" imageName:@"tabHome_off" selectedImageName:@"tabHome"];
    _homevc = home;
    EquipmenVC *devices = [[EquipmenVC alloc] init];
    [self addOneChildVC:devices title:@"Devices" imageName:@"tabDevices_off" selectedImageName:@"tabDevices"];
    _equipmenvc = devices;
    UserVC *user = [[UserVC alloc] init];
    [self addOneChildVC:user title:@"Center" imageName:@"tabCenter_off" selectedImageName:@"tabCenter"];
    _uservc  = user;
    MoreViewController *more = [[MoreViewController alloc] init];
    [self addOneChildVC:more title:@"User" imageName:@"tabUser_off" selectedImageName:@"tabUser"];
    _morevc = more; */
    
}
/*- (void)addOneChildVC:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageNmae {
    //设置标题
    childVc.title = title;
    if ([childVc class] == [HomeVC class]) {
        childVc.navigationItem.title = @"拜3"; //self.NavigationItemTitle;
    }
    
    
    //设置图标
    childVc.tabBarItem.image = [UIImage imageNamed:imageName];
    //设置选中图标
    UIImage *selectedImage = [UIImage imageNamed:selectedImageNmae];
    if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")) {
        selectedImageNmae = [NSString stringWithFormat:@"%@",[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    }
    childVc.tabBarItem.selectedImage = selectedImage;
    
    //添加导航控制器
    NavigationC *nav = [[NavigationC alloc] initWithRootViewController:childVc];
    [self addChildViewController:nav];
} */


@end
